package com.eagle.depthinspringboot.configuration.condition;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

import java.util.Map;

public class OnPropertySystemCondition implements Condition {
	@Override
	public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {

		Map<String, Object> annotationAttributes = metadata.getAnnotationAttributes(ConditionalOnSystemProperty.class.getName());

		String propertyName = (String) annotationAttributes.get("name");

		String propertyValue = (String) annotationAttributes.get("value");

		//Lenovo
		String sytemName = System.getProperty(propertyName);


		return sytemName.equals(propertyValue);
	}
}
